package cn.hs.service.impl;

import cn.hs.entity.Consult;
import cn.hs.mapper.ConsultMapper;
import cn.hs.service.ConsultService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

/**
 * @ClassName ConsultServiceImpl
 * @Description TODO
 * @Author yyk
 * @Date 2024年10月23日 19:58
 * @Version 1.0
 */

@Service
public class ConsultServiceImpl implements ConsultService {
    @Autowired
   private ConsultMapper consultMapper;
    @Override
    public PageInfo getConsultList(Consult consult, int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<Consult> all = consultMapper.findAll(consult);

        PageInfo pageInfo = new PageInfo(all);
        return pageInfo;

    }

    @Override
    public int insert(Consult consult) {
        return consultMapper.insert(consult);
    }

    @Override
    public int updateByPrimaryKey(Consult consult) {
        return consultMapper.updateByPrimaryKey(consult);
    }

    @Override
    public int deleteByPrimaryKey(Integer id) {
        return consultMapper.deleteByPrimaryKey(Long.valueOf(id));
    }

    @Override
    public PageInfo findById(Integer id, int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<Consult> byId = consultMapper.findById(id);

        PageInfo pageInfo = new PageInfo(byId);
        return pageInfo;


    }

    @Override
    public PageInfo getConsultList2(Consult consult, int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<Consult> all2 = consultMapper.findAll2(consult);

        PageInfo pageInfo = new PageInfo(all2);
        return pageInfo;
    }


}
